﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tradex.Connectivity.Tests {

    [TestClass]
    public class ConnectorHostParametersTests {

        /// <summary>
        /// Checks parsing of the /Connection key.
        /// </summary>
        [TestMethod]
        public void Parse_Connection () {
            ConnectorHostParameters p = ConnectorHostParameters_Accessor.Parse(new string[] {
                "/Connection:Test"
            });
            Assert.AreEqual ("Test", p.Connection);
        }

        /// <summary>
        /// Checks parsing of the /Interface key.
        /// </summary>
        [TestMethod]
        public void Parse_Interface() {
            ConnectorHostParameters p = ConnectorHostParameters_Accessor.Parse(new string[] {
                "/Interface"
            });
            Assert.AreEqual(true, p.Interface);
        }

        /// <summary>
        /// Checks parsing of the /Manual key.
        /// </summary>
        [TestMethod]
        public void Parse_Manual() {
            ConnectorHostParameters p = ConnectorHostParameters_Accessor.Parse(new string[] {
                "/Manual"
            });
            Assert.AreEqual(true, p.Manual);
        }

        /// <summary>
        /// Checks parsing of the ConnectorKey and ConnectorName
        /// </summary>
        [TestMethod]
        public void Parse_KeyConnector() {
            ConnectorHostParameters p = ConnectorHostParameters_Accessor.Parse(new string[] {
                "ConnectorName", "ConnectorKey"
            });
            Assert.AreEqual("ConnectorKey", p.Key);
            Assert.AreEqual("ConnectorName", p.Connector);
        }

        /// <summary>
        /// Checks parsing of all elements together
        /// </summary>
        [TestMethod]
        public void Parse_AllSwitches() {
            ConnectorHostParameters p = ConnectorHostParameters_Accessor.Parse(new string[] {
                "ConnectorName", "ConnectorKey", "/Interface", "/Manual",  "/Connection:Test"
            });
            Assert.AreEqual("ConnectorKey", p.Key);
            Assert.AreEqual("ConnectorName", p.Connector);
            Assert.AreEqual("Test", p.Connection);
            Assert.AreEqual(true, p.Interface);
            Assert.AreEqual(true, p.Manual);
        }


        /// <summary>
        /// Checks parsing of no entries - checks default values are ok.
        /// </summary>
        [TestMethod]
        public void Parse_Defaults() {
            ConnectorHostParameters p = ConnectorHostParameters_Accessor.Parse(new string[] {
            });
            Assert.AreEqual(null, p.Key);
            Assert.AreEqual(null, p.Connector);
            Assert.AreEqual(null, p.Connection);
            Assert.AreEqual(false, p.Interface);
            Assert.AreEqual(false, p.Manual);
        }

    }
}
